home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / stv.lha / STV / ISA / artifact / globeref.st < prev    next >
Text File  |  1993-07-23  |  2KB  |  59 lines

  1.  
  2. " Global Var References by Tom Wrensch & Gene Korienek
  3.  
  4.   This will add a method to the SystemDictionary 
  5.   (Smalltalk) to open a method browser on all the
  6.   methods that use a particular global variable.
  7.   For example, If you want to see all the methods
  8.   that access the global variable Sources you could
  9.   do this:
  10.  
  11.         Smalltalk globalUsers: #Sources.
  12.  
  13.   Remember that classes are also global variables,
  14.   so you can also do stuff like this:
  15.  
  16.         Smalltalk globalUsers: #TextPane.
  17.  
  18.   To get all the methods that use the class TextPane
  19.   directly.
  20.  
  21.   You may notice that the method browser does not
  22.   highlight the place where the global variable is
  23.   used.  This is unfortunate, but I haven't figured
  24.   out how to fix it without major changes to the 
  25.   method browser."!
  26.  
  27. !Behavior methods !
  28.  
  29. usersOf: anObject
  30.     "Answer a collection of methods of myself and my
  31.      subclasses that use the object anObject."
  32. | methods |
  33. methods := OrderedCollection new: 30.
  34. self withAllSubclasses do: [:class |
  35. class methodDictionary do: [:method |
  36.     (method includes: anObject with: nil)
  37.         ifTrue: [methods add: method]].
  38.     class class methodDictionary do: [:method |
  39.         (method includes: anObject with: nil)
  40.             ifTrue: [methods add: method]]].
  41. ^methods! !
  42.  
  43.  
  44. !SystemDictionary methods !
  45.  
  46. globalUsers: aSymbol
  47.         "Pop-up a method list window for the
  48.          global variable referenced by aSymbol."
  49.     | methods assoc |
  50.     CursorManager execute change.
  51.     assoc := Smalltalk
  52.         associationAt: aSymbol
  53.         ifAbsent: [Association new].
  54.     methods := Object usersOf: assoc.
  55.     CursorManager normal change.
  56.     MethodBrowser new
  57.         label: 'Users of ', assoc key printString;
  58.         openOn: methods! !
  59.